package com.cqjtu.tto.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.cqjtu.tto.service.PermissionsRoleService;
import com.cqjtu.tto.vo.Results;
import com.cqjtu.tto.vo.params.PermissionsRoleParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 *@author：monkey-L
 *@description: 
 *@date: 11:56 2021/12/12
*/
@RestController
@Api(tags = "角色-权限模块")
public class PermissionsRoleController {

    @Autowired
    private PermissionsRoleService permissionsRoleService;

//    @SaCheckRole("admin")
    @PostMapping("permissionsRoleAdd")
    @ApiOperation(value = "为角色赋权")
    public Results permissionsRoleAdd(@RequestBody PermissionsRoleParam permissionsRoleParam) {
        return permissionsRoleService.permissionsRoleAdd(permissionsRoleParam);
    }

//    @SaCheckRole("admin")
    @PostMapping("permissionsRoleDelete")
    @ApiOperation(value = "削减角色权限")
    public Results permissionsRoleDelete(@RequestBody PermissionsRoleParam permissionsRoleParam) {
        return permissionsRoleService.permissionsRoleDelete(permissionsRoleParam);
    }

//    @SaCheckRole("admin")
    @PostMapping("permissionsRoleUpdate")
    @ApiOperation(value = "修改角色权限")
    public Results permissionsRoleUpdate(@RequestBody PermissionsRoleParam permissionsRoleParam) {
        return permissionsRoleService.permissionsRoleUpdate(permissionsRoleParam);
    }

//    @SaCheckRole("admin")
    @PostMapping("permissionsRoleSelect")
    @ApiOperation(value = "查询角色的所有权限")
    public Results permissionsRoleSelect(String roleName) {
        return permissionsRoleService.permissionsRoleSelect(roleName);
    }
}
